package com.lemon.smartsafety.utils.app;

import com.lemon.smartsafety.app.ApplicationInfo;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.utils.common.StringUtils;

/**
 * Created by Cooliean on 16/2/16.
 */
public class UserTypeHelper {
    /**
     * 是否是机构人员
     *
     * @return
     */
    public static boolean isGovUser() {
        String userType = new SharedPreferencesHelper(IApplication.context()).getUserType();
        if (ApplicationInfo.CHARGER_CODE.equals(userType) || ApplicationInfo.MANAGER_CODE.equals(userType)) {
            return true;
        }
        return false;
    }

    /**
     * 获取用户类型的描述
     * @return
     */
    public static String getUserTypeName() {
        //String userType = new SharedPreferencesHelper(IApplication.context()).getUserType();
        return new SharedPreferencesHelper(IApplication.context()).getUserTypeName();
    }
    /**
     * 获取用户类型的代码
     * @return
     */
    public static String getUserTypeValue() {
        String userType = new SharedPreferencesHelper(IApplication.context()).getUserType();
        return userType;
    }


    /**
     * 是否是企业人员
     *
     * @return
     */
    public static boolean isComUser() {
        String userType = new SharedPreferencesHelper(IApplication.context()).getUserType();
        if (ApplicationInfo.MAJOR_CODE.equals(userType) || ApplicationInfo.SAFER_CODE.equals(userType) || ApplicationInfo.WORKER_CODE.equals(userType)) {
            return true;
        }
        return false;
    }

    /**
     * 是否是企业安全负责人
     *
     * @return
     */
    public static boolean isSafer() {
        SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(IApplication.context());
        if (ApplicationInfo.SAFER_CODE.equalsIgnoreCase(StringUtils.nullValue(sharedPreferencesHelper.getUserType()))) {
            return true;
        }
        return false;
    }




    /**
     * 是否是企业负责人
     *
     * @return
     */
    public static boolean isMajor() {
        SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(IApplication.context());
        if (ApplicationInfo.MAJOR_CODE.equalsIgnoreCase(StringUtils.nullValue(sharedPreferencesHelper.getUserType()))) {
            return true;
        }
        return false;
    }


    /**
     * 是否是企业安全员
     *
     * @return
     */
    public static boolean isWorker() {
        SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(IApplication.context());
        if (ApplicationInfo.WORKER_CODE.equalsIgnoreCase(StringUtils.nullValue(sharedPreferencesHelper.getUserType()))) {
            return true;
        }
        return false;
    }


    /**
     * 是否是企业安全负责人 或者是  企业负责人
     * @return
     */
    public static boolean isSaferOrMajor(){
        if (isSafer() || isMajor()) {
            return true;
        }
        return false;
    }


    /**
     * 是否是数据采集员
     *
     * @return
     */
    public static boolean isDataCollection() {
        SharedPreferencesHelper sharedPreferencesHelper = new SharedPreferencesHelper(IApplication.context());
        if (ApplicationInfo.DATA_COLLECTOR.equalsIgnoreCase(StringUtils.nullValue(sharedPreferencesHelper.getUserType()))) {
            return true;
        }
        return false;
    }


    /**
     * 是否可以使用安全巡查模块
     *
     * @return
     */
    public static boolean canUseSafeFire() {
        if (isSafer() || isDataCollection() || isWorker()) {
            return true;
        }
        return false;
    }

    /**
     * 是否是维保人员
     *
     * @param userType 用户类型码
     * @return
     */
    public static boolean isKeeper(String userType) {
        if (ApplicationInfo.KEEP_MAJOR.equals(userType) || ApplicationInfo.KEEP_WORKER.equals(userType)) {
            return true;
        }
        return false;
    }
}
